{% extends "cmdb/mequipment/index.html" %}

{% block right_content %}
<div id="right_menu">
    <div>
        <button id="add" class="btn btn-info hint hint-top" style="float:left;margin-bottom: 15px;" data-hint="添加一个维修记录"><span class="glyphicon glyphicon-plus"></span></button>
       <!--  <form class="form-inline" style="float: right">
            <div class="form-group">
                <label class="sr-only" for="search">Search</label>
                <input type="search" class="form-control" id="search" placeholder="Search" style="width:100%">
            </div>
            <button type="submit" class="btn btn-primary"></button>
        </form> -->
    </div>
    <table id="example" style="table-layout:fixed;" class="table table-bordered table-hover">
        <thead >
            <td class="col">编号</td>
            <td class="col">设备序列号</td>
            <td class="col">报修日期</td>
            <td class="col">报修人</td>
            <td class="col">修复日期</td>
            <td class="col" style="width:15%">操作</td>
        </thead>
        {% if equipment_maint_list %}
        {% for maint in equipment_maint_list %}
        <tr>
            <td class="col">{{ maint.id }}</td>
            <td class="col">{{ maint.serial_num }}</td>
            <td class="col">{{ maint.maint_time }}</td>
            <td class="col">{{ maint.maint_man }}</td>
            <td class="col">{{ maint.repair_time }}</td>
            <td class="col">
                <a class="edit_item  hint hint-top mouse_pointer" data-id="{{ maint.id }}" data-toggle="modal" data-target="#editItem" data-hint="编辑保修信息">
                        <span class="glyphicon glyphicon-edit"></span>
                </a>&nbsp;
                <a data-id="{{ maint.id }}" class="hint hint-top mouse_pointer" data-toggle="modal" data-target="#lookItem" data-hint="查看维修记录">
                        <span class="glyphicon glyphicon-eye-open"></span>
                </a>
                </div>
            </td>
        </tr>
        {% endfor %}
        {% endif %}
    </table>

    <div>
        <span>跳转到
         <select class="pagei">
             {% for temppage in page_list %}
             <option value="{{ temppage }}" {% ifequal temppage page %}selected {% endifequal %}>{{ temppage }}</option>
             {% endfor %}
         </select>页
        </span>
        <span style="padding-left: 28%;">每页{{ page_num }}条，第{{ page }}页，共{{ count }}条，共{{ page_total }}页</span>
        <span style="float:right;padding-right:50px">
            <a class="word hint hint-top" href="{% url 'equipment:repairinfo' %}?page=1" data-hint="首页"><span class="glyphicon glyphicon-fast-backward"></span></a>
            {% ifnotequal page 1 %}&nbsp;
            <a class="hint hint-top" href="{% url 'equipment:repairinfo' %}?page={{ page|add:-1 }}" data-hint="上一页"><span class="glyphicon glyphicon-step-backward"></span></a>
            {% endifnotequal %}

            {% ifnotequal page page_total %}&nbsp;
            <a class="hint hint-top" href="{% url  'equipment:repairinfo' %}?page={{ page|add:1 }}" data-hint="下一页"><span class="glyphicon glyphicon-step-forward"></span></a>
            {% endifnotequal %}&nbsp;
            <a class="word hint hint-top" href="{% url 'equipment:repairinfo' %}?page={{ page_total }}" data-hint="尾页"><span class="glyphicon glyphicon-fast-forward"></span></a>
        </span>
    </div>
</div>

<!-- 模态框（Modal）编辑用户资料 -->
<div class="modal fade" id="lookItem" tabindex="-1" role="dialog" aria-labelledby="lookItemLabel">
    <div class="modal-dialog">
        <div class="modal-content" style="width:800px">
            <div class="modal-header">
                <button type="button" class="close"
                        data-dismiss="modal">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    详情
                </h4>
            </div>
            <div class="modal-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <td class="col1">设备序列号</td>
                        <td class="col2">报修日期</td>
                        <td class="col3">报修人</td>
                        <td class="col4">故障现象</td>
                    </thead>
                    <tr>
                        <td class="col1" id="serial_num"></td>
                        <td class="col2" id="maint_time"></td>
                        <td class="col3" id="maint_man"></td>
                        <td class="col4" id="problem"></td>
                    </tr>
                </table>

                <table class="table table-bordered table-hover">
                    <thead>
                        <td class="col1">修复日期</td>
                        <td class="col2">到场人</td>
                        <td class="col3">维修人</td>
                        <td class="col4">解决方法</td>
                    </thead>
                    <tr>
                        <td class="col1" id="repair_time"></td>
                        <td class="col2" id="present"></td>
                        <td class="col3" id="pepair_man"></td>
                        <td class="col4" id="resolution"></td>
                    </tr>
                </table>

                <table class="table table-bordered table-hover">
                    <thead>
                        <td colspan="4">备注</td>
                    </thead>
                    <tr>
                        <td colspan="4" id="comment"></td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
$(".pagei").change(function(){
        var index=$(this).children('option:selected').val();
        window.location.href="{% url 'equipment:repairinfo' %}?page=" +index;
});
$("#add").click(function(){
    window.location.href="{% url 'equipment:raddinfo' %}";
});
$(".edit_item").click(function(){
    var id = $(this).data("id");
    window.location.href="{% url 'equipment:reditinfo' %}?page=" + {{ page }} + "&id="+id;
});

 $("#lookItem").on('show.bs.modal',function(event){
    var button = $(event.relatedTarget);
    var id = button.data("id");
    var urls = "{% url 'equipment:rgetaction' %}";
    postdata = {id:id};
    var jsonstr = $.ajax({
		url : urls,
		type : "POST",
		data : postdata,
		async : false,
		cache : false
	});
	var jsonobj = eval('(' + jsonstr.responseText + ')');
	if(jsonobj.status==0){
		alert(jsonobj.message);
	}else{
	    $(this).find('#serial_num').html(jsonobj.data.serial_num);
	    $(this).find('#maint_time').html(jsonobj.data.maint_time);
	    $(this).find('#maint_man').html(jsonobj.data.maint_man);
	    $(this).find('#problem').html(jsonobj.data.problem);
	    $(this).find('#repair_time').html(jsonobj.data.repair_time);
	    $(this).find('#present').html(jsonobj.data.present);
	    $(this).find('#pepair_man').html(jsonobj.data.pepair_man);
	    $(this).find('#resolution').html(jsonobj.data.resolution);
	    $(this).find('#comment').html(jsonobj.data.comment);
    }
});

</script>
{% endblock  %}

